Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for extension_dn #879

Closed

Conversation

MaciejMierzwa
Copy link

@MaciejMierzwa MaciejMierzwa commented Jul 12, 2023

Description

Add support for extension domain name, similar to how it's done for security plugin. More about that in the task: [Extensions] Add support for extension_dns list in extensions.yml file#2730

Issues Resolved

[Extensions] Add support for extension_dns list in extensions.yml file#2730

Currently the implementation looks like this:

  1. During extension initialization via REST call, DNs are passed in the request body:
curl -XPOST -k -u user:password "https://localhost:9200/_extensions/initialize" -H "Content-Type:application/json" --data '{ "name":"hello-world", "uniqueId":"hello-world2", "hostAddress":"127.0.0.1", "port":"4500", "version":"1.0", "opensearchVersion":"3.0.0", "minimumCompatibleVersion":"3.0.0", "dependencies":[{"uniqueId":"test1","version":"2.0.0"},{"uniqueId":"test2","version":"3.0.0"}], "extension_dn": "CN=extension-0.example.com,OU=node,O=node,L=test,DC=de" }'
  1. Request gets parsed and forwarded to extension node, extension_dn get's sent with InitializeExtensionRequest object
  2. At this point on the extension side after SSL handshake the DNs get compared, error is thrown if it's incorrect

PR on openserch-core side: opensearch-project/OpenSearch#8665

I'm in the process of writing tests. Main issue I'm facing right now is that I'm wondering if the overall process looks good. Is the validation logic on the right side? Maybe core side should wait for extension response and then accept/reject call?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Maciej Mierzwa <[email protected]>
@cwperks
Copy link
Member

cwperks commented Jul 13, 2023

Hey @MaciejMierzwa, validation of the peer certificate's dn (distinguished name) should be wholly encapsulated within the security plugin. This setting helps mTLS between opensearch node <-> extension node be more secure by verifying that the extension's certificate (peer certificate) matches a list of known distinguished names and if not, deny the transport request as coming from an unknown origin.

Take a look at this method here which is used on the receiving end of a transport request (SecurityRequestHandler) to determine if a transport request has originated from another node within the cluster (intra-cluster request) or from another cluster that is trusted (cross-cluster request where nodes share same root ca)

That method uses the DefaultInterClusterRequestEvaluator.isInterClusterRequest which compares the peer certificates dn with the static list of node_dns in opensearch.yml and from the dynamic list of node_dns in the security index (sourced from the nodes_dn.yml file)

The logic in particular that is interesting is this condition here where it extracts the principal (dn) from the peer certificate and checks if it matches any known node_dns.

The alternative to matching exactly the distinguished name is for the peer certificate to have a known OID (Object Identifier) and then it doesn't need to match a known node_dn. More details about that can be found here. I am a little weaker on the subject alt names and how to properly issue certs with matching OIDs so that an exact node_dn match does not need to occur. I believe its added for convenience to prevent needing to add new node_dns every time a new certificate has been issued when nodes are added to the cluster and instead as long as they share the OID from the subjectAltName its granted permission to join the cluster.

@MaciejMierzwa
Copy link
Author

Hi @cwperks thank you for reply. I spent some time debugging the flow. The issue I'm thinking about right now is that during handshake list of DNs is loaded from file or index. (like you mentioned).
Current implementation sends this data in json body in request since design moved away from static config so this data is not available during initial transport request. I'm thinking about maybe loading this info into the index config at first stages of calls. For example around this place: https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/extensions/ExtensionsManager.java#L294C29-L294C29. Then this info could be used during handshake and during consecutive calls between extension and cluster.
Let me know what do you think about it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants